﻿<UserControl x:Class="CodeSHARPer.View.Tools.RecentFilesView"
             xmlns:cmd="clr-namespace:CodeSHARPer"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300">
    
    <Grid>
        <ListView Margin="3"
                  SelectionMode="Single"
                  HorizontalAlignment="Stretch"
                  VerticalAlignment="Stretch"
                  SnapsToDevicePixels="True"
                  BorderThickness="0"
                  ItemsSource="{Binding OpenedFilesManager.LastOpenedFiles}">
            <ListView.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="Open Container Folder"
                              Command="{Binding OpenFileInContainerFolderCommand}"
                              CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}"/>
                    <MenuItem Header="Remove"
                              Command="{Binding RemoveFileCommand}"
                              CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}"/>
                </ContextMenu>
            </ListView.ContextMenu>
            <ListView.View>
                <GridView>
                    <GridView.ColumnHeaderContainerStyle>
                        <!-- To hide the header of a ListView you can modify the Visibility property of the ColumnHeaderContainer by overriding the style. -->
                        <Style>
                            <Setter Property="FrameworkElement.Visibility" Value="Collapsed"/>
                        </Style>
                    </GridView.ColumnHeaderContainerStyle>
                    <GridViewColumn >
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock>
                                    <Hyperlink Command="cmd:AppCommand.LoadFile" CommandParameter="{Binding PathFileName}"
                                               NavigateUri="{Binding PathFileName}">
                                        <TextBlock Text="{Binding FileName}" ToolTip="{Binding PathFileName}"/>
                                    </Hyperlink>
                                </TextBlock>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>
    </Grid>
</UserControl>
